package com.rd.student.jiaji.class3.xumingze.exam;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.LinkedList;
import java.util.Scanner;

public class Test01 {
    String name;
    int chinese;
    int math;

    public Test01(String name, int chinese, int math){
        this.name = name;
        this.chinese = chinese;
        this.math = math;

        System.out.println(name + "总分为:" + (chinese + math));
    }

    @Override
    public String toString() {
        return name + "总分为:" + (chinese + math);
    }

    public static void main(String[] args) throws IOException {

        LinkedList list = new LinkedList();

        Scanner scanner = new Scanner(System.in);
        for(int i = 0;i < 3;i++){
            System.out.println("请输入姓名:");
            String name = scanner.next();
            System.out.println("请输入语文成绩:");
            int chinese = scanner.nextInt();
            System.out.println("请输入数学成绩:");
            int math = scanner.nextInt();
            Test01 student = new Test01(name,chinese,math);
            list.add(student);
        }

        File file = new File("Student.txt");
        file.createNewFile();
        Writer writer = new FileWriter(file);
        writer.write(list.toString());
        writer.close();

//        Test01 student1 = new Test01("梅西",100,100);
//        Test01 student2 = new Test01("C罗",1,5);
//        Test01 student3 = new Test01("坎塞洛",80,79);

//        LinkedList list = new LinkedList();
//        list.add(student1);
//        list.add(student2);
//        list.add(student3);

    }
}

